<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>商品推广</title>

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/bootstrap.min.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/fonts/line-icons.css}">

    <link rel="stylesheet" th:href="@{/assets/plugins/morris/morris.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/main.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/responsive.css}">

    <!--<link th:href="@{/fileroot/css/fileroot.css}" media="all" rel="stylesheet" type="text/css"/>

    <link rel="stylesheet" th:href="@{https://use.fontawesome.com/releases/v5.5.0/css/all.css}" crossorigin="anonymous">

    <link th:href="@{/fileroot/themes/explorer-fas/theme.css}" media="all" rel="stylesheet" type="text/css"/>-->

    <script th:src="@{/ckeditor/ckeditor.js}" type="text/javascript"></script>

    <script th:src="@{/assets/js/jquery-min.js}"></script>

    <link rel="stylesheet" th:href="@{/fileroot/bootstrap4.1.3/css/bootstrap.css}" crossorigin="anonymous">
    <link th:href="@{/fileroot/fileinput/css/fileinput.css}" media="all" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" th:href="@{/fileroot/fontawesome/css/all.css}" crossorigin="anonymous">
    <link th:href="@{/fileroot/fileinput/themes/explorer-fas/theme.css}" media="all" rel="stylesheet" type="text/css"/>
    <script th:src="@{/fileroot/jquery-3.4.1.min.js}" crossorigin="anonymous"></script>
    <script th:src="@{/fileroot/bootstrap4.1.3/js/bootstrap.bundle.min.js}" crossorigin="anonymous"></script>

    <script th:src="@{/fileroot/fileinput/js/plugins/piexif.js}" type="text/javascript"></script>
    <script th:src="@{/fileroot/fileinput/js/plugins/sortable.js}" type="text/javascript"></script>
    <!-- 预览时,图片排序,用处不大 -->
    <script th:src="@{/fileroot/fileinput/js/fileinput.js}" type="text/javascript"></script>
    <script th:src="@{/fileroot/fileinput/themes/fas/theme.js}" type="text/javascript"></script><!-- 图标插件 -->
    <script th:src="@{/fileroot/fileinput/themes/explorer-fas/theme.js}" type="text/javascript"></script>
    <script th:src="@{/fileroot/fileinput/js/locales/zh.js}" type="text/javascript"></script> <!-- 语言插件 -->
</head>
<body>
<div class="app header-default side-nav-dark">
    <div class="layout">

        <div class="page-container pl-0">
            <div class="main-content">
                <div class="container-fluid">
                    <div class="card">
                        <div class="card-header border-bottom">
                            <h4 class="card-title">商品信息</h4>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-lg-10 col-md-12 col-xs-12">
                                    <form action="/admin/product/addOrModify" onsubmit="return check();" role="form"
                                          method="post" id="form-validation" novalidate="novalidate"
                                          th:object="${product}">
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">商品名称</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="*{id}" hidden class="form-control"
                                                           name="id" placeholder="商品名称">
                                                    <input type="text" th:value="*{name}" class="form-control"
                                                           name="name" placeholder="商品名称">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <input type="text" class="form-control" name="name"
                                                           placeholder="商品名称">
                                                </div>
                                                <div id="nameInfo" class="position-absolute"
                                                     style="right: -98px;top: 10px;width: 100px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">商家</label>
                                            <div class="col-sm-10">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="${merchant.name}" class="form-control"
                                                           disabled="disabled" name="businessId" placeholder="商家姓名">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <select class="form-control custom-select chosen" name="businessId"
                                                            required style="color: #232323;">
                                                        <div th:each="merchant : ${merchants}">
                                                            <option th:value="${merchant.id}"
                                                                    th:text="${merchant.name}"></option>
                                                        </div>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">商品价格</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="*{price}" class="form-control"
                                                           name="price" placeholder="商品价格">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <input type="text" class="form-control" name="price"
                                                           placeholder="商品价格">
                                                </div>
                                                <div id="priceInfo" class="position-absolute"
                                                     style="right: -98px;top: 10px;width: 100px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">供应商分配比例(%)</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="*{merRatio}" class="form-control"
                                                           name="merRatio" placeholder="供应商分配比例" onblur="ratio('mer','refer');" required=""
                                                           aria-required="true">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <input type="text" class="form-control" name="merRatio" onblur="ratio('mer','refer');"
                                                           placeholder="供应商分配比例" required="" aria-required="true">
                                                </div>
                                                <div id="merInfo" class="position-absolute"
                                                     style="right: -118px;top: 10px;width: 120px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">推荐人分配比例(%)</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="*{referRatio}" onblur="ratio('refer','mer');" class="form-control"
                                                           name="referRatio" placeholder="推荐人分配比例">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <input type="text" class="form-control" onblur="ratio('refer','mer');" name="referRatio"
                                                           placeholder="推荐人分配比例">
                                                </div>
                                                <div id="referInfo" class="position-absolute"
                                                     style="right: -118px;top: 10px;width: 120px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">返还比例(%)</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <input type="text" th:value="*{returnRatio}" onfocus=this.blur() class="form-control"
                                                           name="returnRatio" placeholder="商品返还比例">
                                                </div>
                                                <div th:if="${product==null}">
                                                    <input type="text" class="form-control" name="returnRatio"
                                                           onfocus=this.blur() placeholder="商品返还比例">
                                                </div>
                                                <div id="returnInfo" class="position-absolute"
                                                     style="right: -118px;top: 10px;width: 120px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">商品图片</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product != null}">
                                                    <input th:id="image-input" th:value="*{image}" name="image" hidden>
                                                </div>
                                                <div th:if="${product == null}">
                                                    <input th:id="image-input" name="image" hidden>
                                                </div>
                                                <div class="file-loading">
                                                    <input id="file-zh" multiple name="images" type="file">
                                                </div>
                                                <div id="imageInfo" class="position-absolute"
                                                     style="right: -98px;top: 10px;width: 100px;"></div>
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label control-label">商品介绍</label>
                                            <div class="col-sm-10 position-relative">
                                                <div th:if="${product!=null}">
                                                    <textarea th:text="*{introduce}" name="introduce" th:id="editor">
                                                    </textarea>
                                                </div>
                                                <div th:if="${product==null}">
                                                    <textarea name="introduce" th:id="editor">
                                                    </textarea>
                                                </div>
                                                <div id="introInfo" class="position-absolute"
                                                     style="right: -98px;top: 10px;width: 100px;"></div>
                                                <script type="text/javascript">
                                                    CKEDITOR.replace("editor");
                                                </script>
                                            </div>
                                        </div>
                                        <span th:if="${product==null}"><button type="submit"
                                                                               class="btn btn-outline-success">添加</button></span>
                                        <span th:unless="${product==null}"><button type="submit"
                                                                                   class="btn btn-outline-info">修改</button></span>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div id="preloader">
    <div class="loader" id="loader-1"></div>
</div>

<script th:src="@{/assets/js/popper.min.js}"></script>
<script th:src="@{/assets/js/bootstrap.min.js}"></script>
<script th:src="@{/assets/js/jquery.app.js}"></script>
<script th:src="@{/assets/js/main.js}"></script>

<script th:src="@{/assets/plugins/morris/morris.min.js}"></script>
<script th:src="@{/assets/plugins/raphael/raphael-min.js}"></script>


<script type="text/javascript">
    var url = [];
    var imgInfo = [];
    var images = $("#image-input").val();
    var isImages = images.indexOf(";");
    if (isImages > 0) {
        url = images.split(";");
        for (var i = 0; i < url.length; i++) {
            imgInfo[i] = {
                caption: "商品图片",
                key: i,
                extra: {id: 100},
                url: "/admin/product/delImage?id=" + $('input[name="id"]').val() + "&imgName=" + url[i]
            };
        }
    } else {
        url.push(images);
        imgInfo.push({
            caption: "商品图片",
            key: 0,
            extra: {id: 100},
            url: "/admin/product/delImage?id=" + $('input[name="id"]').val() + "&imgName=" + images
        });
    }
    /* $('#file-zh').fileroot({
      theme: 'fas', //设置主题
      language: 'zh',//设置语言
      textEncoding : "UTF-8",//文本编码
      uploadUrl: '/admin/product/uploadImage',//上传的地址
      allowedFileExtensions: ['jpg', 'png', 'gif'],//接收的文件后缀
      /!*uploadAsync: true, //默认异步上传
      showUpload: true, //是否显示上传按钮
      showRemove : true, //显示移除按钮
      showPreview : true, //是否显示预览
      showCaption: true,//是否显示标题
      browseClass: "btn btn-primary", //按钮样式
      dropZoneEnabled: false,//是否显示拖拽区域
      enctype: 'multipart/form-data',
      validateInitialCount:false,*!/
      /!*enableResumableUpload: true,
      resumableUploadOptions: {
       //如果您希望测试文件中先前上传的部分区块，请在下面取消注释
       //到服务器，然后从该点继续上传
       // testUrl: "http://localhost/test-upload.php"
      },*!/

      uploadExtraData: {
       'uploadToken': 'SOME-TOKEN', //用于访问控制/安全
      },
      maxFileCount: 5, //最大文件数
      allowedFileTypes: ['image'],    //只允许图片
      showCancel: true,
      initialPreviewAsData: true,
      overwriteInitial: false,
      // initialPreview: [],          //如果以前已上传预览文件
      // initialPreviewConfig: [],    //如果您先前已上传预览文件
      //下面几个就是初始化预览图片的配置
      initialPreviewAsData: true,
      initialPreviewFileType: 'image',
      initialPreview:url,
      initialPreviewConfig: imgInfo,
      layoutTemplates :{
       // actionDelete:'', //去除上传预览的缩略图中的删除图标
       // actionUpload:'',//去除上传预览缩略图中的上传图片；
       actionZoom:''   //去除上传预览缩略图中的查看详情预览的缩略图标。
      }
      /!*,
      deleteUrl: "#"*!/
     });
     $('#file-zh').on('fileuploaded', function(event,data, previewId, index) {
      var image = $("#image-input").val();
      if (image != "" && image != null){
        image += ","+data.response.url;
      }else {
        image = data.response.url;
      }
      $("#image-input").val(image);
      // alert(data.response.list[0].fname);
      console.log('File Uploaded', 'ID: ' + data );
      /!*!//在上传成功事件中将服务器返回的所需数据，添加到该文件对应的div中
      $('#' + previewId).attr('fileid', data.response.fileid);*!/
     }).on('fileuploaderror', function(event, data, msg) {
      console.log('File Upload Error', 'ID: ' + data.fileId + ', Thumb ID: ' + data.previewId);
     });
     $('#file-zh').on('filepredelete', function(event, key) {

     }).on('filedeleted', function(event, key,data) {//删除返回结果
      console.log('Key = ' + data);
      // console.log('Key = ' + key);
     }).on('filesuccessremove', function (event, id) { //filesuccessremove事件：图片上传成功后，点击删除按钮的回调函数
      /!*if (some_processing_function(id)) {
       var newUrl="";
       for (var i = 0; i < url.length; i++) {
        if (i == id){
         continue;
        }
        if (i > 0){
         newUrl += ","+url[i];
        } else {
         newUrl += url[i];
        }
       }
       $("#image-input").val(newUrl);
       console.log('Uploaded thumbnail successfully removed');
      } else {
       return false;
      }  *!/
      /!*!//在移除事件里取出所需数据，并执行相应的删除指令
      delete($('#' + previewId).attr('fileid'));*!/
       /!*var newUrl="";
       for (var i = 0; i < url.length; i++) {
        if (i == id){
         continue;
        }
        if (i > 0){
         newUrl += ","+url[i];
        } else {
         newUrl += url[i];
        }
       }
       $("#image-input").val(newUrl);

      var images = $("#image-input").val();
      var isImages = images.indexOf(",");
      if (isImages>0){
       url = images.split(",");
       for (var i = 0; i < url.length; i++) {
        imgInfo[i] = {caption: "商品图片",key:i,extra: {id: 100},url:"/admin/product/delImage?id="+$('input[name="id"]').val()+"&imgName="+url[i]};
       }
      } else {
       url.push(images);
       imgInfo.push({caption: "商品图片",key:0,extra: {id: 100},url:"/admin/product/delImage?id="+$('input[name="id"]').val()+"&imgName="+images});
      }*!/
      $("#file-zh").fileroot("refresh",{showBrowse:false});
     });*/

    $("#file-zh").fileinput({
        language: 'zh',
        theme: 'fas',
        uploadUrl: '/admin/product/uploadImage',
        overwriteInitial: false,
        dropZoneEnabled: true,//是否显示拖拽区域
        textEncoding: 'UTF-8',
        allowedFileExtensions: ['jpg', 'jpeg', 'gif', 'png'],//接收的文件后缀
        //allowedFileTypes: ['image', 'video', 'flash'],
        //minImageWidth: 50, //图片的最小宽度
        //minImageHeight: 50,//图片的最小高度
        //maxImageWidth: 1000,//图片的最大宽度
        //maxImageHeight: 1000,//图片的最大高度
        //maxFileSize:0,//单位为kb，如果为0表示不限制文件大小
        //minFileCount: 0,
        maxFileCount: 5, //表示允许同时上传的最大文件个数
        uploadAsync: true, //默认异步上传
        showUpload: true, //是否显示上传按钮
        showRemove: false, //显示移除按钮
        showClose: false,//显示右上角叉
        showPreview: true, //是否显示预览
        showCaption: true,//是否显示标题
        browseClass: "btn btn-info", //按钮样式
        dropZoneEnabled: false,//是否显示拖拽区域
        /*enableResumableUpload: true,//是否显示上传按钮 默认false
        validateInitialCount: false,//Upload aborted beyond 3 retries for file 问题诱因*/
        //下面几个就是初始化预览图片的配置
        enctype: 'multipart/form-data',
        initialPreviewAsData: true,
        initialPreviewFileType: 'image',
        initialPreview: url,
        initialPreviewConfig: imgInfo,
        layoutTemplates: {
            // actionDelete:'', //去除上传预览的缩略图中的删除图标
            // actionUpload:'',//去除上传预览缩略图中的上传图片；
            actionZoom: ''   //去除上传预览缩略图中的查看详情预览的缩略图标。
        }/*,
  slugCallback: function (filename) {//不规则命名处理.
   return filename.replace('(', '_').replace(']', '_');
  }*/
    });
    //上传成功触发
    $("#file-zh").on("fileuploaded", function (event, data, previewId, index) {
        /*//上传图片名称
        var upload_img_name = previewId.substring(previewId.indexOf("_", index+1));
        var url=$("#image-input").val();
        if (url != null || url !=''){
         $("#image-input").val(url+data.response.message+upload_img_name+';');
        }
        console.log('upload_img_name:'+upload_img_name);*/

        var image = $("#image-input").val();
        if (image != "" && image != null) {
            image += ";" + data.response.url;
        } else {
            image = data.response.url;
        }
        $("#image-input").val(image);
    });
    //缩略图片删除成功后，触发事件 后续处理
    $("#file-zh").on('filedeleted', function (event, key, data) {
        console.log('key = ' + key);
        var newUrl = "";
        if (url.length > 0) {
            for (var i = 0; i < url.length; i++) {
                if (i != key && url[i] != "") {
                    if (newUrl.length == 0) {
                        newUrl = url[i];
                    } else {
                        newUrl += ";" + url[i];
                    }
                } else {
                    url[i] = "";
                }
            }
        }
        console.log('newUrl = ' + newUrl);
        console.log('url = ' + url);

        $("#image-input").val(newUrl);
    });
    /*//上传成功后，缩略删除图片，触发事件 data包含图片本来得 name
    $('#file-zh').on('filesuccessremove', function(event, key, data) {
     console.log('event:'+event);
     console.log('key:'+key);
     console.log('data:'+data);
     var index=data.indexOf("_");
     //删除图片名称
     var del_img_name = key.substring(key.indexOf("_", index));
     console.log('del_img_name:'+del_img_name);
     //当前上传的图片，拼接后字符串
     var url=$("#image-input").val();
     console.log("原始url:"+url);
     var img_names = url.split(";");
     var del_name;
     for (var i = 0; i < img_names.length; i++) {
      if(img_names[i].indexOf(del_img_name) >= 0){
       del_name=img_names[i];
      }
     }
     console.log("当前删除url:"+del_name);
     url=url.replace(del_name+";","");
     console.log("删除后url:"+url);
     $.get("/admin/product/delImage",{"id":$('input[name="id"]').val(),"imgName":del_name},function (data) {
      if(data.code == 200){
       $("#image-input").val(url);
      }else {
       console.log("code:"+data.code+",message:"+data.message);
      }
     })
    });
    //移除按钮触发事件
    $('#file-zh').on('filecleared', function() {
     var testVal = $("#image-input").val();
     var url=$("#image-input").val();
     console.log(url);
     if (testVal){
      $.get("",{"urls":url},function (data) {
       if(data.code == 200){
        $("#image-input").val('');
        console.log("code:"+data.code+",message:"+data.message);
       }else {
        console.log("code:"+data.code+",message:"+data.message);
       }
      })
     }
    });*/

    //表单提交验证
    function check() {
        var status = 0;
        //ajax异步验证
        $.ajax({
            url: "/com/verification/product",
            data: {
                name: $("input[name='name']").val(), price: $("input[name='price']").val(),
                merRatio: $("input[name='merRatio']").val(), referRatio: $("input[name='referRatio']").val(),
                image: $("input[name='image']").val(), introduce: $("textarea[name='introduce']").val()
            },
            type: "post",
            dateType: "json",
            async: false,
            success: function (data) {
                var data = eval("(" + data + ")");

                if (data["nam"].length > 1) {
                    $("#nameInfo").text(data["nam"]);
                    $("#nameInfo").css("color", "#dc3545");
                } else {
                    $("#nameInfo").text(data.nam);
                }

                if (data.pri.length > 1) {
                    $("#priceInfo").text(data.pri);
                    if (data.pri.length >= 7) {
                        $("#priceInfo").css("top", "-3px");
                    }
                    $("#priceInfo").css("color", "#dc3545");
                } else {
                    $("#priceInfo").text(data.pri);
                }

                if (data.imga.length > 1) {
                    $("#imageInfo").text(data.imga);
                    if (data.imga.length >= 7) {
                        $("#imageInfo").css("top", "-3px");
                    }
                    $("#imageInfo").css("color", "#dc3545");
                } else {
                    $("#imageInfo").text("");
                }

                if (data.intro.length > 1) {
                    $("#introInfo").text(data.intro);
                    if (data.intro.length >= 7) {
                        $("#introInfo").css("top", "-3px");
                    }
                    $("#introInfo").css("color", "#dc3545");
                } else {
                    $("#introInfo").text("");
                }

                if (judgeNotNull($("input[name='name']").val())) {
                    $("#nameInfo").text("");
                }
                if (judgeNotNull($("input[name='price']").val())) {
                    $("#priceInfo").text("");
                }
                if (judgeNotNull($("input[name='image']").val())) {
                    $("#imageInfo").text("");
                }
                if (judgeNotNull($("#editor").val())) {
                    $("#introInfo").text("");
                }

                var name = $("input[name='name']").val();
                var price = $("input[name='price']").val();
                var image = $("input[name='image']").val();
                var intro = CKEDITOR.instances.editor.getData();

                var mer = $("input[name='merRatio']").val();
                var refer = $("input[name='referRatio']").val();
                if (!judgeNotNull(mer)) {
                    $("#merInfo").text("未输入供应商分配比例！");
                    $("#merInfo").css("top", "-3px");
                    $("#merInfo").css("color", "#dc3545");
                }else {
                    $("#merInfo").text("");
                }
                if (!judgeNotNull(refer)) {
                    $("#referInfo").text("未输入推荐人分配比例！");
                    $("#referInfo").css("top", "-3px");
                    $("#referInfo").css("color", "#dc3545");
                } else {
                    $("#referInfo").text("");
                }
                if (judgeNotNull(name) && judgeNotNull(price) && judgeNotNull(image) && judgeNotNull(intro)
                    && judgeNotNull(mer) && judgeNotNull(refer)) {
                    status = 1;
                }
            }
        });
        if (status == 0){
            return false;
        }
    }

    //商品比例验证
    function ratio(dom,dom1) {
        var ratio = parseDecimal($("input[name='"+dom+"Ratio']").val());
        var ratio1 = parseDecimal($("input[name='"+dom1+"Ratio']").val());
        if (ratio == 100){
            $("#"+dom+"Info").text();
            $("#"+dom1+"Info").text();
            $("input[name='"+dom1+"Ratio']").val(0);
            $("input[name='returnRatio']").val(0);
        }
        if (!judgeNotNull(ratio1)){
            return false;
        }
        // var ratio1 = $("input[name='"+dom1+"Ratio']").val();
        // var ratio2 = $("input[name='"+dom2+"Ratio']").val();
        if (ratio != null && ratio != undefined){
            if (ratio >=0 && ratio < 100) {
                var sum = ratio1 + ratio;
                console.log(sum);
                if (sum <= 100) {
                    $("#" + dom + "Info").text();
                    var rt = 100 - sum;
                    console.log(100 - sum);
                    console.log(":"+rt);
                    $("input[name='returnRatio']").val(rt);
                    // $("input[name='returnRatio']").attr("readonly","readonly");
                } else {
                    $("#" + dom + "Info").text(showInfo(dom, 1));
                    $("#" + dom + "Info").css("top", "-3px");
                    $("#" + dom + "Info").css("color", "#dc3545");
                }
            } else {
                $("#" + dom + "Info").text(showInfo(dom, 1));
                $("#" + dom + "Info").css("top", "-3px");
                $("#" + dom + "Info").css("color", "#dc3545");
            }
        } else {
            $("#"+dom+"Info").text(showInfo(dom,0));
            $("#"+dom+"Info").css("top", "-3px");
            $("#"+dom+"Info").css("color", "#dc3545");
        }
    }
    
    function showInfo(dom,type) {
        if (type == 0){
            switch (dom) {
                case "mer":return "请输入供应商分配比例！";
                case "refer":return "请输入推荐人分配比例！";
                case "return":return "请输入商品返还比例！";
            }
        }
        if (type == 1){
            switch (dom) {
                case "mer":return "请输入正确的供应商分配比例。";
                case "refer":return "请输入正确的推荐人分配比例。";
                case "return":return "请输入正确的商品返还比例。";
            }
        }
    }

    function parseDecimal(n) {
        var f = parseFloat(n);
        if (isNaN(f)) {
            return;
        }
        f = Math.round(n*100)/100;
        return f;
    }

    function judgeNotNull(dom) {
        if (dom != null && dom != "" && dom != undefined) {
            return true;
        }else {
            return false;
        }
    }
</script>

<script th:src="@{/fileroot/file-input.js}" type="text/javascript"></script>

</body>

</html>